package com.qf.miaosha_service.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisUtil {
    private static JedisPool pool;

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(50);
        config.setMaxIdle(20);
        config.setMinIdle(5);
        pool = new JedisPool(config,"127.0.0.1",6379);
    }

    //    获取jedis
    public static Jedis getJedis(){
        if (pool != null){
            Jedis jedis = pool.getResource();
            return jedis;
        }
        return null;
    }
}
